package com.demo.javamail.controller;

import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author liangliang
 */
@Controller
@RequestMapping("mail")
public class MailController {

    /***
     * 首页展示
     */
    @RequestMapping("/index")
    public String index() {
        return "index";
    }

    /**
     * 数据处理
     */
    @RequestMapping(value = "/process",method = RequestMethod.POST)
    @ResponseBody
    public void mailProcess(HttpServletRequest request, HttpServletResponse response) throws IOException {
        String topic = request.getParameter("topic");
        String content = request.getParameter("content");
        String contact = request.getParameter("contact");

        System.out.println(topic);
        JSONObject result = new JSONObject();
        result.put("status",200);
        result.put("data",topic);
        response.getWriter().write(result.toJSONString());


    }
}
